<div class="center">
	<div class="home">
    	<div class="home_left">
        	<?php echo $this->partial('member/menu.phtml',array('uCount' => $this->uCount,'menuId'=>$this->menuId,'user'=>$this->user,'account'=>$this->account)); ?>
        </div>
    	<div class="home_right">
			<div class="addressbooktop">
            	<i>地址簿</i>
                <div class="addressbookname">
                	<h1>我的收货地址簿</h1>
                    <p>在此您可以对您的收货地址进行管理，最多保存10个有效地址。</p>
                </div>
            </div>
			<div class="addressbooktx">
                <form id="saveAddr" action="/member/saveaddress" method="post">
            	<table>
                	<tr>
                        <td class="aleft"><span>*</span>收货人姓名：</td>
                        <td>
                            <!--class="texting"输入状态，class=""空为平常状态-->
                            <div class="dztext"><?= $this->formText('linkMan',null,array('class'=>'required')) ?></div>
                        </td>
                    </tr>
                	<tr>
                        <td class="aleft"><span>*</span>所在国家或地区：</td>
                        <td>
                            <div class="guojiabox">
                                <div class="guyojiatext"><input type="text" readonly="readonly" value="<?= $this->city->Name ?>" id="stateText" name="stateText" /><a href="javascript:void(0)"></a></div>
                                <input type="hidden" class="state" value="<?= $this->city->Id ?>" id="state" name="state" />
                                <div class="guojiaceng" style="display:none;">
                                    <div class="remen">
                                        <h2>热门国家和地区</h2>
                                        <ul class="countrylist">
                                            <li><a href="#" id="c_us" cid="1">美国</a></li>
                                            <li><a href="#" cid="2">加拿大</a></li>
                                            <li><a href="#" cid="3">澳大利亚</a></li>
                                            <li><a href="#" cid="47">日本</a></li>
                                            <li><a href="#" cid="39">台湾</a></li>
                                            <li><a href="#" cid="4">新西兰</a></li>
                                            <li><a href="#" cid="5">英国</a></li>
                                            <li><a href="#" cid="42">马来西亚</a></li>
                                        </ul>
                                    </div>
                                    <div class="allcountry">
                                        <h2>全部国家和地区</h2>
                                        <ul class="countryzm">
                                            <?
                                            foreach ($this->words as $char){
                                            ?>
                                            <li <?= $char=='A'?'class="zmon"':'' ?>><a href="#"><?= $char ?></a></li>
                                            <? }
                                            ?>

                                        </ul>
                                        <div id="countryTab">
                                        <?
                                        foreach ($this->words as $char){
                                        ?>
                                    <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                                        <?
                                        $citys= Application_Model_city::GetBySortCode($char);
                                        foreach ($citys as $city){
                                        ?>
                                            <li><a href="#" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                            <? } ?>
                                        </ul>
                                        <?
                                            }
                                        ?>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </td>
                    </tr>
                	<tr>
                        <td class="aleft"><span>*</span>详细地址：</td>
                        <td><div class="dztext"><?= $this->formTextarea('street',NULL,array('class'=>'required')) ?><span>您的详细英文收货地址(含州,城市等)，国家不需重复填写</span></div></td>
                    </tr>
                	<tr>
                        <td class="aleft"><span>*</span>邮政编码：</td>
                        <td><div class="dztext youbian"><?= $this->formText('postcode',NULL,array('class'=>'required')) ?></div></td>
                    </tr>
                	<tr>
                        <td class="aleft"><span>*</span>联系电话：</td>
                        <td><div class="dztext"><?= $this->formText('mobile',NULL,array('class'=>'required')) ?><span>固定电话或手机均可</span></div></td>
                    </tr>
                	
                </table>
                <div class="addressbaocun">
                	<a class="addressok" href="#"><span>添加地址</span></a>
                </div>
                </form>
            </div>
            
            <div class="addressbox">
            	<div class="addressboxtop">
                    <h2>已保存的有效地址</h2>
                </div>
                <div class="addresstable">
                	<table>
                    	<tr>
                        	<th class="b1">收件人</th>
                        	<th class="b2">国家</th>
                        	<th class="b3">收货信息</th>
                            <th class="b5">操作</th>
                        </tr>
                        <!--tr普通class为空，鼠标经过为class="hui"，选为默认地址的tr为class="moren"-->
                        <? foreach ($this->address as $item){ ?>
                    	<tr class="<?= $item == $this->address[0]?'moren':''  ?>  ">
                        	<td class="b1"><?= $item->linkMan ?></td>
                        	<td class="b2"><?= $item->StateText ?></td>
                        	<td class="b3">
                            	<h2><?= $item->Street ?></h2>
                                <ul>
                                	<li>邮编：<?= $item->Postcode ?></li>
                                	<li>电话：<?= $item->mobile ?></li>
                                </ul>
                            </td>
                            <td class="b5">
                                <a href="/member/deladdress/id/<?= $item->Id ?>">删除</a>
                            </td>
                            
                        </tr>
                        <? } ?>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
    //---国家选择器---
    $('.guojiabox').hover(function(){
        //$('.guojiaceng').show();
    },function(){
        $('.guojiaceng').hide();
    });
    $('.guyojiatext').click(function(){
        $('.guojiaceng').show();
    });
    $('.countrylist a').bind('click',function(){
        var city =$(this).text();
        $('#stateText').val(city);
        
        $('.guojiabox #state').val($(this).attr('cid'));
        $('.guojiaceng').hide();
        return false;
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
    $('.dztext span').click(function(){
        $(this).parent().find(':input').focus();
    });
    $('.addressbooktx :input').keydown(function(e){
        if(e.keyCode>=48&& e.keyCode <= 90){
            $(this).parent().find('span').hide();
        }else if($(this).val()==''){
            $(this).parent().find('span').show();
        }
    });
    $(':input').hover(function(){
        $(this).addClass('texting');
    }).mouseout(function(){
        $(this).removeClass('texting');
    });
    $('.addressok').click(function(){
        $('#saveAddr').submit();
        return false;
    });
    $('#saveAddr').validate();
});
</script>